﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Data;

namespace WEALTH
{
    public partial class index : System.Web.UI.Page
    {
        private ExcuteDao InformationManage = new ExcuteDao();

        public string ffNewsStr = string.Empty;

        public string marqueeText = string.Empty;

        public string ffActionNewsStr = string.Empty;
        public string strImg = string.Empty;
        ExcuteDao dao = new ExcuteDao();
        protected void Page_Load(object sender, EventArgs e)
        {
            ffNewsStr = GetSubTextByListID(30);
            ffActionNewsStr = GetSubTextByListID(29);
            DataTable dt1 = dao.GET_IndexImage(1);
            if (dt1 != null && dt1.Rows.Count > 0)
            {
                if (dt1.Rows[0]["Image_Isdel"].ToString().Equals("False"))
                {
                    strImg += " <a href=\"#\"><img src=\"IndexImageShow.aspx?Image_ID=1\" alt=\"\" title=\"\" /></a>";
                }
            }
            DataTable dt2 = dao.GET_IndexImage(2);
            if (dt2 != null && dt2.Rows.Count > 0)
            {
                if (dt2.Rows[0]["Image_Isdel"].ToString().Equals("False"))
                {
                    strImg += " <a href=\"#\"><img src=\"IndexImageShow.aspx?Image_ID=2\" alt=\"\" title=\"\" /></a>";
                }
            }
            DataTable dt3 = dao.GET_IndexImage(3);
            if (dt3 != null && dt3.Rows.Count > 0)
            {
                if (dt3.Rows[0]["Image_Isdel"].ToString().Equals("False"))
                {
                    strImg += " <a href=\"#\"><img src=\"IndexImageShow.aspx?Image_ID=3\" alt=\"\" title=\"\" /></a>";
                }
            }
            DataTable dt4 = dao.GET_IndexImage(4);
            if (dt4 != null && dt4.Rows.Count > 0)
            {
                if (dt4.Rows[0]["Image_Isdel"].ToString().Equals("False"))
                {
                    strImg += " <a href=\"#\"><img src=\"IndexImageShow.aspx?Image_ID=4\" alt=\"\" title=\"\" /></a>";
                }
            }
            DataTable dt5 = dao.GET_IndexImage(5);
            if (dt5 != null && dt5.Rows.Count > 0)
            {
                if (dt5.Rows[0]["Image_Isdel"].ToString().Equals("False"))
                {
                    strImg += " <a href=\"#\"><img src=\"IndexImageShow.aspx?Image_ID=5\" alt=\"\" title=\"\" /></a>";
                }
            }

            if (!IsPostBack)
            {
                SetMarqueeText();
            }
        }

        public string GetSubTextByListID(int menuId)
        {
            StringBuilder str = new StringBuilder();

            DataTable dtInformation = InformationManage.Get_List(Convert.ToInt32(menuId));
            if (dtInformation.Rows.Count > 0)
            {
                string url = "ListView.aspx?listviewid=" + SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["listTitle"].ToString()) +
                    "&menutype=枫帆研究";
                str.Append("<div class=\"tabright_box\">");
                str.Append("<a href=" + url + " target=\"_blank\">");
                str.Append(AppFunction.GetString(SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["listTitle"].ToString()), 32));
                str.Append("</a>");
                str.Append("<p>");
                str.Append(AppFunction.GetString(SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["listjianjie"].ToString()), 56));
                str.Append("<a href=" + url + " target=\"_blank\">【详细】</a></p>");
                str.Append("</div>");
                str.Append("<dl>");

                for (int i = 1; i < dtInformation.Rows.Count && i < 6; i++)
                {
                    url = "ListView.aspx?listviewid=" + SpecialCharHandler.HtmlDiscode(dtInformation.Rows[i]["listID"].ToString()) +
                        "&menutype=枫帆研究";
                    str.Append("<dt><a href=" + url + " target=\"_blank\">" + SpecialCharHandler.HtmlDiscode(dtInformation.Rows[i]["listTitle"].ToString()) + "</a></dt>");

                }
                str.Append("<dl>");
            }

            return str.ToString();
        }

        public void SetMarqueeText()
        {
            DataTable dt1 = dao.GET_IdxMarquee("首页滚动文字");

            if (dt1 != null && dt1.Rows.Count > 0)
            {
                marqueeText = dt1.Rows[0]["textValue"].ToString();
            }
        }
    }
}